#!/usr/bin/env python

import wx
import sys

class Frame(wx.Frame):
	
	def __init__(self, parent, id, title):
		print "Frame__init__"
		wx.Frame.__init__(self, parent, id, title)
	
class App(wx.App):

	def __init__(self, redirect=True, filename=None):
		print "App__init__"
		wx.App.__init__(self, redirect, filename)
		
	def OnInit(self):
		print "OnInit"
		self.frame = Frame(parent=None, id=-1, title='Startup')
		self.frame.Show()
		self.SetTopWindow(self.frame)
		print >> sys.stderr, "A pretend error message"
		return True

	def OnExit(self):
		print "OnExit"
		
def main():
	#This redirect output to a file named redirectOutput.txt.
	#app = App(redirect=True, filename="redirectOutput.txt")
	
	#This redirect output to a wxPython frame
	app = App(redirect=True)
	
	print "before MainLoop"
	
	for i in range(1,1000):
		print(i)
		
	app.MainLoop()
	print "After MainLoop"
	
if __name__ == '__main__':
	main()
	